package com.elong.businesstravel.modules.home;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.apache.http.Header;
import org.apache.http.client.HttpResponseException;

import android.R.integer;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.TextView;

import com.android.support.jhf.androidpulltorefresh.library.PullToRefreshBase;
import com.android.support.jhf.androidpulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.android.support.jhf.androidpulltorefresh.library.PullToRefreshListView;
import com.android.support.jhf.androidpulltorefresh.library.PullToRefreshBase.Mode;
import com.android.support.jhf.handlerui.HandlerPostUI;
import com.android.support.jhf.handlerui.HandlerToastUI;
import com.android.support.jhf.network.ErrorExceptionHandler;
import com.android.support.jhf.network.IErrorListener;
import com.android.support.jhf.network.NetworkClient;
import com.android.support.jhf.network.loopj.android.http.ResponseHandlerInterface;
import com.android.support.jhf.utils.DateUtils;
import com.android.support.jhf.utils.ImageUtil;
import com.android.support.jhf.utils.MobileUtils;
import com.elong.businesstravel.R;
import com.elong.businesstravel.base.Constant;
import com.elong.businesstravel.base.activity.BaseActivity;
import com.elong.businesstravel.base.dialog.CustomListDialog;
import com.elong.businesstravel.base.dialog.CustomListDialog.CustomListDialogItem;
import com.elong.businesstravel.base.recorder.Recorder;
import com.elong.businesstravel.base.umeng.socialize.CustomShareDialog;
import com.elong.businesstravel.base.utils.AppUserId;
import com.elong.businesstravel.base.view.TitleNavBarView;
import com.elong.businesstravel.entitys.HotelDocs;
import com.elong.businesstravel.entitys.HotelInfo;
import com.elong.businesstravel.entitys.HotelPrice;
import com.elong.businesstravel.entitys.HotelReviews;
import com.elong.businesstravel.entitys.HotelPrice.RatePlanInfo;
import com.elong.businesstravel.entitys.MemberManaged;
import com.elong.businesstravel.modules.home.adapter.HotelDetailAdapter;
import com.elong.businesstravel.modules.login.LoginActivity;
import com.elong.businesstravel.protocol.ProtocolDef;
import com.elong.businesstravel.protocol.hotel.GetHotelInfoRequest;
import com.elong.businesstravel.protocol.hotel.GetHotelInfoResponse;
import com.elong.businesstravel.protocol.hotel.GetHotelPriceRequest;
import com.elong.businesstravel.protocol.hotel.GetHotelPriceResponse;
import com.elong.businesstravel.protocol.hotel.GetHotelReviewsRequest;
import com.elong.businesstravel.protocol.hotel.GetHotelReviewsResponse;
import com.elong.businesstravel.protocol.login.MemberGetManagedRequest;
import com.elong.businesstravel.protocol.login.MemberGetManagedResponse;
import com.elong.businesstravel.wxapi.WXEntryActivity;
import com.umeng.socialize.media.CircleShareContent;
import com.umeng.socialize.media.MailShareContent;
import com.umeng.socialize.media.QQShareContent;
import com.umeng.socialize.media.SinaShareContent;
import com.umeng.socialize.media.SmsShareContent;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.media.WeiXinShareContent;

/**
 * 酒店详情
 * 
 * @author lenovo
 * 
 */
public class HotelDetailActivity extends BaseActivity implements
		OnScrollListener, OnCheckedChangeListener, OnClickListener {

	private List<Object> mHoteList = new ArrayList<Object>();
	private List<MemberManaged> mMemberManageds = new ArrayList<MemberManaged>();

	private PullToRefreshListView mListView;
	private View mTabView;
	private View mDateView;
	private HotelDetailAdapter adapter;
	private RadioButton mRadioButton0;
	private RadioButton mRadioButton1;
	private RadioButton mRadioButton2;

	private HotelDocs mHotelDocs;
	private HotelInfo mHotelInfo;
	private HotelPrice mHotelPrice;
	/** 选择酒店房间 */
	private RatePlanInfo mRatePlanInfo;
	private List<HotelReviews> mHotelReviews = new ArrayList<HotelReviews>();
	private ArrayList<HotelInfo> mAdapterHeadHotelInfos = new ArrayList<HotelInfo>();
	/** 0"All",1"Prepay" */
	private int mProduct;

	private int firstVisibleItem = 0;
	/** 评论翻页 */
	private int mReviewPage = 1;

	private CustomShareDialog mCustomShareDialog;

	private Bitmap mShareBitmap;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_hotel_detail);

		mHotelDocs = (HotelDocs) getIntent().getSerializableExtra("hotelDocs");
		mProduct = getIntent().getIntExtra("product", 0);
		
		mTabView = findViewById(R.id.tabButton);
		mTabView.setVisibility(View.GONE);

		mDateView = findViewById(R.id.dateView);
		mDateView.setOnClickListener(this);
		mDateView.setVisibility(View.GONE);
		setDateView();

		mListView = (PullToRefreshListView) findViewById(R.id.listView);
		// mListView.setMode(Mode.PULL_FROM_END);
		mListView.setMode(Mode.DISABLED);
		mListView.setOnScrollListener(this);
		adapter = new HotelDetailAdapter(mContext, mHoteList,
				mAdapterHeadHotelInfos, mTabView, mMemberManageds,
				mHotelDocs.deduction);
		mListView.setAdapter(adapter);
		mListView.setOnRefreshListener(new OnRefreshListener<ListView>() {

			@Override
			public void onRefresh(PullToRefreshBase<ListView> refreshView) {
				if (1 == adapter.getCurrentTab()) {
					getHotelReviews(true);
				}
				mHandler.sendEmptyMessage(1);
			}
		});

		adapter.setRadio0OnCheckedChangeListener(this);
		adapter.setRadio1OnCheckedChangeListener(this);
		adapter.setRadio2OnCheckedChangeListener(this);

		mRadioButton0 = (RadioButton) mTabView.findViewById(R.id.radio0);
		mRadioButton0.setOnCheckedChangeListener(this);
		mRadioButton1 = (RadioButton) mTabView.findViewById(R.id.radio1);
		mRadioButton1.setOnCheckedChangeListener(this);
		mRadioButton2 = (RadioButton) mTabView.findViewById(R.id.radio2);
		mRadioButton2.setOnCheckedChangeListener(this);

		getHotelInfo();

		getHotelPrice();

		setTitleNavBar();

		mShareBitmap = ImageUtil.drawable2Bitmap(mContext.getResources()
				.getDrawable(R.drawable.ic_share));

		if (!TextUtils.isEmpty(AppUserId.getUserId(mContext))) {
			memberGetManaged();
		}

		setListener();
	}

	@Override
	protected void setListener() {
		ImageView shareImageView = (ImageView) findViewById(R.id.shareImageView);
		shareImageView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				shareHotelDetail();
				stopPlayback();
			}
		});
		ImageView phoneImageView = (ImageView) findViewById(R.id.phoneImageView);
		phoneImageView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				List<String> phoneList = new ArrayList<String>();
				phoneList.add("差旅通:" + Constant.ELONG_CUSTOMER_SERVICE_PHONE);
				if (!TextUtils.isEmpty(mHotelDocs.phone)) {
					phoneList.add(" 酒店 :" + mHotelDocs.phone);
				}
				showPhoneSelectDialog(phoneList);
				stopPlayback();
			}
		});
	}

	private void showPhoneSelectDialog(List<String> phoneList) {
		CustomListDialog customListDialog = CustomListDialog
				.getCustomListDialog(mContext,
						com.android.support.jhf.R.style.DialogFromDownToUp);
		final List<CustomListDialogItem> customListDialogItems = new ArrayList<CustomListDialog.CustomListDialogItem>();
		for (int i = 0; i < phoneList.size(); i++) {
			CustomListDialogItem customListDialogItem = new CustomListDialogItem();
			customListDialogItem.text = phoneList.get(i);
			customListDialogItem.textColor = getResources().getColor(
					R.color.btn_bg_blue);
			customListDialogItem.textSize = 18;
			customListDialogItems.add(customListDialogItem);
		}

		customListDialog.setMessage(customListDialogItems);
		customListDialog.setTitle("拨打电话");
		customListDialog.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				CustomListDialogItem customListDialogItem = customListDialogItems
						.get(arg2);
				MobileUtils.callPhoneActivity(mContext,
						customListDialogItem.text.split(":")[1],
						Intent.ACTION_VIEW);
			}
		});
		customListDialog.show();
	}

	private void memberGetManaged() {
		NetworkClient.getNetworkClient().PostRequest(
				new MemberGetManagedRequest(mContext),
				new MemberGetManagedResponse() {

					@Override
					public void onResponse(
							ResponseHandlerInterface responseHandlerInterface) {

						HandlerPostUI.getHandlerPostUI(new Runnable() {

							@Override
							public void run() {
								mMemberManageds.clear();
								mMemberManageds.add(memberManaged);
								adapter.notifyDataSetChanged();
							}
						});
					}

				});
	}

	private void setDateView() {
		String start = DateUtils.dateFormat(DateUtils.getDateMillis(
				mApplication.mHotelSearchCondition.getStartDate(), "yyyyMMdd"),
				"MM月dd日");
		String end = DateUtils.dateFormat(DateUtils.getDateMillis(
				mApplication.mHotelSearchCondition.getEndDate(), "yyyyMMdd"),
				"MM月dd日");
		TextView inDateTextView = (TextView) mDateView
				.findViewById(R.id.inDateTextView);
		TextView outDateTextView = (TextView) mDateView
				.findViewById(R.id.outTextView);
		inDateTextView.setText(start);
		outDateTextView.setText(end);

		ViewGroup dikouDescLayout = (ViewGroup) mDateView
				.findViewById(R.id.dikouDescLayout);
		if (null == mMemberManageds || 0 == mMemberManageds.size()) {
			dikouDescLayout.setVisibility(View.GONE);
		} else {
			dikouDescLayout.setVisibility(View.VISIBLE);
			TextView dikouDescMoneyTextView = (TextView) mDateView
					.findViewById(R.id.dikouDescMoneyTextView);
			dikouDescMoneyTextView.setText(mMemberManageds.get(0).uscore);
		}
	}

	@Override
	protected void setTitleNavBar() {
		TitleNavBarView titleNavBarView = (TitleNavBarView) findViewById(R.id.titleNavBarView);
		titleNavBarView.setMessage("酒店详情");
		titleNavBarView.setLeftDrawableImage(R.drawable.btn_title_back);
		titleNavBarView.setLeftButtonImageString(0, "返回", R.color.text_blue);
		titleNavBarView.setLeftButtonOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// 返回
				finish();
			}
		});
		titleNavBarView.setRightButtonVisibility(View.INVISIBLE);

		mListView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				if (0 == adapter.getCurrentTab()) {
					if (0 == position) {
					} else if (1 == position) {
					} else if (2 == position) {
						goHotelDestineDateActivity();
					} else {
						// 点击客房,预订
						RatePlanInfo ratePlanInfo = (RatePlanInfo) adapter
								.getItem(position);
						mRatePlanInfo = ratePlanInfo;
						if ("true".equalsIgnoreCase(ratePlanInfo.Status)) {
							goLogin(ratePlanInfo);
						} else {
							HandlerToastUI.getHandlerToastUI(mContext,
									"已经满房，无法预订");
						}
					}
				}
			}
		});
	}

	private void goLogin(RatePlanInfo ratePlanInfo) {
		if (AppUserId.getUserId(mContext).equals("")) {
			// Intent intent = new Intent(mContext, WXEntryActivity.class);
			Intent intent = new Intent(mContext, LoginActivity.class);
			startActivityForResult(intent, 1);
		} else {
			goSubmitOrders(ratePlanInfo);
		}
	}

	/**
	 * 跳转到天谢谢订单
	 */
	private void goSubmitOrders(RatePlanInfo ratePlanInfo) {
		Intent intent = new Intent(mContext, SubmitOrdersActivity.class);
		intent.putExtra("hotelPrice", mHotelPrice);
		intent.putExtra("ratePlanInfo", ratePlanInfo);
		intent.putExtra("hotelDocs", mHotelDocs);
		startActivity(intent);
	}

	@Override
	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

		switch (buttonView.getId()) {
		case R.id.radio0: {
			if (isChecked) {
				
				stopPlayback();

				if (View.VISIBLE != mTabView.getVisibility()) {
					if (mRadioButton0.isChecked()) {
						return;
					}
				} else {

				}
				mListView.setMode(Mode.DISABLED);
				ListView listView = mListView.getRefreshableView();
				listView.setDividerHeight(1);
				mHoteList.clear();
				if (null != mHotelPrice) {
					for (int i = 0; i < mHotelPrice.mRoomInfos.size(); i++) {
						mHoteList
								.addAll(mHotelPrice.mRoomInfos.get(i).RatePlans);
					}
				}
				if (0 == mHoteList.size()) {
					mHoteList.add("暂无酒店报价信息");
				}
				adapter.notifyDataSetChanged();
				mRadioButton0.setChecked(true);
				adapter.setCurrentTab(0);

				if (firstVisibleItem >= 2) {
					if (View.VISIBLE != mDateView.getVisibility()) {
						mDateView.setVisibility(View.VISIBLE);
					}
					if (View.GONE != mTabView.getVisibility())
						mTabView.setVisibility(View.GONE);
				}

			}
			break;
		}
		case R.id.radio1: {
			if (isChecked) {

				if (View.VISIBLE != mTabView.getVisibility()) {
					if (mRadioButton1.isChecked()) {
						return;
					}
				} else {

				}
				mListView.setMode(Mode.PULL_FROM_END);
				ListView listView = mListView.getRefreshableView();
				listView.setDividerHeight(1);
				mHoteList.clear();
				if (0 != mHotelReviews.size()) {
					mHoteList.addAll(mHotelReviews);
				} else {
					getHotelReviews(false);
				}
				adapter.notifyDataSetChanged();
				mRadioButton1.setChecked(true);
				adapter.setCurrentTab(1);
			}
			break;
		}
		case R.id.radio2: {
			if (isChecked) {

				stopPlayback();
				
				if (View.VISIBLE != mTabView.getVisibility()) {
					if (mRadioButton2.isChecked()) {
						return;
					}
				} else {

				}
				mListView.setMode(Mode.DISABLED);
				ListView listView = mListView.getRefreshableView();
				listView.setDividerHeight(1);
				mHoteList.clear();
				// if (null == mHotelInfo) {
				// mHoteList.add("暂无酒店信息");
				// } else {
				mHoteList.add("1");
				mHoteList.add("2");
				mHoteList.add("3");
				// }
				adapter.notifyDataSetChanged();
				mRadioButton2.setChecked(true);
				adapter.setCurrentTab(2);
			}
			break;
		}
		default:
			break;
		}

	}

	@Override
	public void onScroll(AbsListView view, int firstVisibleItem,
			int visibleItemCount, int totalItemCount) {
		this.firstVisibleItem = firstVisibleItem;

		if (0 == firstVisibleItem) {
			mDateView.setVisibility(View.GONE);
			mTabView.setVisibility(View.GONE);
		} else if (0 == adapter.getCurrentTab()) {

			if (1 == firstVisibleItem) {
				mDateView.setVisibility(View.GONE);
				mTabView.setVisibility(View.GONE);
			} else if (2 == firstVisibleItem) {
				if (0 == adapter.getCurrentTab()) {
					if (View.GONE != mDateView.getVisibility()) {
						mDateView.setVisibility(View.GONE);
					}
				} else {
					if (View.GONE != mTabView.getVisibility())
						mTabView.setVisibility(View.GONE);
				}
			} else {
				if (0 == adapter.getCurrentTab()) {
					if (View.VISIBLE != mDateView.getVisibility()) {
						mDateView.setVisibility(View.VISIBLE);
					}
				} else {
					if (View.VISIBLE != mTabView.getVisibility())
						mTabView.setVisibility(View.VISIBLE);
				}
			}

		} else {
			if (1 == firstVisibleItem) {
				if (0 == adapter.getCurrentTab()) {
					if (View.GONE != mDateView.getVisibility()) {
						mDateView.setVisibility(View.GONE);
					}
				} else {
					if (View.GONE != mTabView.getVisibility())
						mTabView.setVisibility(View.GONE);
				}
			} else {
				if (0 == adapter.getCurrentTab()) {
					if (View.VISIBLE != mDateView.getVisibility()) {
						mDateView.setVisibility(View.VISIBLE);
					}
				} else {
					if (View.VISIBLE != mTabView.getVisibility())
						mTabView.setVisibility(View.VISIBLE);
				}
			}
		}
	}

	@Override
	public void onScrollStateChanged(AbsListView view, int scrollState) {

	}

	private void getHotelInfo() {
		NetworkClient.getNetworkClient().PostRequest(
				new GetHotelInfoRequest(mContext, mHotelDocs.hotelId),
				new GetHotelInfoResponse() {
					@Override
					public void onResponse(
							final ResponseHandlerInterface responseHandlerInterface) {
						synchronized (HotelDetailActivity.this) {
							HandlerPostUI.getHandlerPostUI(new Runnable() {

								@Override
								public void run() {
									mHotelInfo = ((GetHotelInfoResponse) responseHandlerInterface).hotelInfo;
									mAdapterHeadHotelInfos.add(mHotelInfo);
									mHandler.sendEmptyMessage(0);
								}
							});
						}

					}
				}, null, new IErrorListener() {

					@Override
					public void onFailure(int statusCode, Header[] headers,
							byte[] responseBody, Throwable error) {

						if (null != mContext && mContext instanceof Activity) {
							StringBuffer stringBuffer = new StringBuffer();
							ErrorExceptionHandler.NetworkExceptionHandler(
									stringBuffer, error);
							if (!TextUtils.isEmpty(stringBuffer.toString())) {
								HandlerToastUI.getHandlerToastUI(mContext,
										stringBuffer.toString());
							}
							try {
								if (!((Activity) mContext).isFinishing()) {
									((Activity) mContext).finish();
								}
							} catch (Exception e) {
							}

						}
					}
				});
	}

	private Handler mHandler = new Handler(new Handler.Callback() {

		@Override
		public boolean handleMessage(Message msg) {
			switch (msg.what) {
			case 0: {
				adapter.notifyDataSetChanged();
				break;
			}
			case 1: {
				mListView.onRefreshComplete();
				break;
			}
			default:
				break;
			}
			return false;
		}
	});

	private void goHotelDestineDateActivity() {
		Intent intent = new Intent(mContext, HotelDestineDateActivity.class);
		intent.putExtra("select",
				mApplication.mHotelSearchCondition.mSearchConditionDate);
		startActivityForResult(intent, 0);
		overridePendingTransition(
				R.anim.activity_bottom_top_enter_anim_translate,
				R.anim.activity_alpha_fixed);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.dateView: {
			// 弹出时间框
			goHotelDestineDateActivity();
			break;
		}
		default:
			break;
		}
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		switch (requestCode) {
		case 0: {
			switch (resultCode) {
			case RESULT_OK: {
				mApplication.mHotelSearchCondition.mSearchConditionDate = data
						.getStringExtra("date");
				mApplication.mHotelSearchCondition.mSearchConditionDays = data
						.getStringExtra("days");
				// adapter.notifyDataSetChanged();
				getHotelPrice();
				setDateView();
				break;
			}
			case RESULT_CANCELED: {
				break;
			}
			default:
				break;
			}
			break;
		}
		case 1: {
			// 登陆返回
			switch (resultCode) {
			case RESULT_OK: {
				// 登陆成功
				goSubmitOrders(mRatePlanInfo);
				break;
			}
			case RESULT_CANCELED: {

				break;
			}
			default:
				break;
			}
			break;
		}
		case 2: {
			// 收藏登陆返回
			if (null != adapter) {
				adapter.onActivityResult(requestCode, resultCode, data);
			}
		}
		default:
			break;
		}
	}

	/**
	 * 获取酒店价格
	 */
	private void getHotelPrice() {
		// "All","Prepay","Selfpay"
		String paytype = "";
		if (0 == mProduct) {
			paytype = "All";
		} else if (1 == mProduct) {
			paytype = "Prepay";
		}

		NetworkClient.getNetworkClient().PostRequest(
				new GetHotelPriceRequest(mContext, mHotelDocs.hotelId,
						mApplication.mHotelSearchCondition.getStartDate(),
						mApplication.mHotelSearchCondition.getEndDate(),
						paytype), new GetHotelPriceResponse() {
					@Override
					public void onResponse(
							final ResponseHandlerInterface responseHandlerInterface) {
						synchronized (HotelDetailActivity.this) {
							HandlerPostUI.getHandlerPostUI(new Runnable() {

								@Override
								public void run() {
									mHotelPrice = ((GetHotelPriceResponse) responseHandlerInterface).hotelPrice;
									mHoteList.clear();
									for (int i = 0; i < mHotelPrice.mRoomInfos
											.size(); i++) {
										mHoteList.addAll(mHotelPrice.mRoomInfos
												.get(i).RatePlans);
									}
									if (0 == mHoteList.size()) {
										mHoteList.add("暂无酒店报价信息");
									}
									mHandler.sendEmptyMessage(0);
								}
							});
						}
					}
				}, null, new IErrorListener() {

					@Override
					public void onFailure(int statusCode, Header[] headers,
							byte[] responseBody, Throwable error) {

						HandlerPostUI.getHandlerPostUI(new Runnable() {

							@Override
							public void run() {
								mHoteList.clear();
								if (0 == mHoteList.size()) {
									mHoteList.add("暂无酒店报价信息");
								}
								mHandler.sendEmptyMessage(0);
							}
						});

						// if (null != mContext && mContext instanceof Activity)
						// {
						// StringBuffer stringBuffer = new StringBuffer();
						// ErrorExceptionHandler.NetworkExceptionHandler(
						// stringBuffer, error);
						// if (!TextUtils.isEmpty(stringBuffer.toString())) {
						// HandlerToastUI.getHandlerToastUI(mContext,
						// stringBuffer.toString());
						// }
						// try {
						// if (!((Activity) mContext).isFinishing()) {
						// ((Activity) mContext).finish();
						// }
						// } catch (Exception e) {
						// }

						// }
					}
				});
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		stopPlayback();
	}
	
	private void stopPlayback(){
		if(null != adapter)
			adapter.stopPlayback();
	}

	/**
	 * 获取评论列表
	 */
	private void getHotelReviews(final boolean moreFlag) {
		if (!moreFlag) {
			mReviewPage = 1;
		} else {
			mReviewPage++;
		}
		NetworkClient.getNetworkClient().PostRequest(
				new GetHotelReviewsRequest(mContext, mHotelDocs.hotelId,
						mReviewPage + "", ProtocolDef.PAGE_SIZE + ""),
				new GetHotelReviewsResponse() {
					@Override
					public void onResponse(
							ResponseHandlerInterface responseHandlerInterface) {
						HandlerPostUI.getHandlerPostUI(new Runnable() {

							@Override
							public void run() {
								if (moreFlag) {
									if (0 == hotelReviews.size()) {
										HandlerToastUI.getHandlerToastUI(
												mContext, "没有更多信息");
									} else {
										mHotelReviews.addAll(hotelReviews);
									}
								} else {
									mHotelReviews.clear();
									mHotelReviews.addAll(hotelReviews);
								}
								mHoteList.clear();
								if (0 == mHotelReviews.size()) {
									mHoteList.add("暂无点评信息");
								} else {
									mHoteList.addAll(mHotelReviews);
								}
								mHandler.sendEmptyMessage(0);
							}
						});

					}
				});
	}

	private void shareHotelDetail() {

		if (null == mHotelInfo || null == mHotelInfo.mHotelDetailShareInfo
				|| null == mHotelInfo.mHotelDetailShortShare) {
			return;
		}

		UMImage umImage = new UMImage(mContext,
				mHotelInfo.mHotelDetailShareInfo.imageurl);

		WeiXinShareContent weiXinShareContent = new WeiXinShareContent();
		weiXinShareContent
				.setShareContent(mHotelInfo.mHotelDetailShareInfo.content);
		weiXinShareContent.setTitle(mHotelInfo.mHotelDetailShareInfo.title);
		if (umImage.isUrlMedia()) {
			weiXinShareContent.setShareImage(umImage);
		} else {
			weiXinShareContent
					.setShareImage(new UMImage(mContext, mShareBitmap));
		}

		weiXinShareContent
				.setTargetUrl(mHotelInfo.mHotelDetailShareInfo.shareurl);
		weiXinShareContent
				.setAppWebSite(mHotelInfo.mHotelDetailShareInfo.shareurl);

		CircleShareContent circleShareContent = new CircleShareContent();
		circleShareContent
				.setShareContent(mHotelInfo.mHotelDetailShareInfo.content);
		circleShareContent.setTitle(mHotelInfo.mHotelDetailShareInfo.title);
		if (umImage.isUrlMedia()) {
			circleShareContent.setShareImage(umImage);
		} else {
			circleShareContent
					.setShareImage(new UMImage(mContext, mShareBitmap));
		}
		circleShareContent
				.setTargetUrl(mHotelInfo.mHotelDetailShareInfo.shareurl);
		circleShareContent
				.setAppWebSite(mHotelInfo.mHotelDetailShareInfo.shareurl);

		SinaShareContent sinaShareContent = new SinaShareContent();
		sinaShareContent.setShareContent(mHotelInfo.mHotelDetailShareInfo.title
				+ mHotelInfo.mHotelDetailShareInfo.content + ",详情点击"
				+ mHotelInfo.mHotelDetailShareInfo.shareurl);
		MailShareContent mailShareContent = new MailShareContent();
		mailShareContent.setShareContent(mHotelInfo.mHotelDetailShareInfo.title
				+ mHotelInfo.mHotelDetailShareInfo.content + ",详情点击"
				+ mHotelInfo.mHotelDetailShareInfo.shareurl);

		QQShareContent qqShareContent = new QQShareContent();
		qqShareContent
				.setShareContent(mHotelInfo.mHotelDetailShortShare.content);
		qqShareContent.setTitle(mHotelInfo.mHotelDetailShortShare.title);
		qqShareContent.setTargetUrl(mHotelInfo.mHotelDetailShortShare.shareurl);
		qqShareContent
				.setAppWebSite(mHotelInfo.mHotelDetailShortShare.shareurl);
		if (umImage.isUrlMedia()) {
			qqShareContent.setShareImage(umImage);
		} else {
			qqShareContent.setShareImage(new UMImage(mContext, mShareBitmap));
		}

		SmsShareContent smsShareContent = new SmsShareContent();
		smsShareContent.setShareContent(mHotelInfo.mHotelDetailShareInfo.title
				+ mHotelInfo.mHotelDetailShareInfo.content + ",详情点击"
				+ mHotelInfo.mHotelDetailShareInfo.shareurl);

		mCustomShareDialog = new CustomShareDialog(mContext,
				com.android.support.jhf.R.style.DialogFromDownToUp);
		mCustomShareDialog.setTitleMessage("酒店分享", "把这家酒店的简介和地址发送给你的朋友");
		mCustomShareDialog.setShareContent(weiXinShareContent,
				circleShareContent, sinaShareContent, mailShareContent,
				qqShareContent, smsShareContent);
		mCustomShareDialog.show();
	}

}
